<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <title>07_3点运算符</title>
</head>
<body>
<!--
* 用途
1. rest(可变)参数
    * 用来取代 arguments 但比 arguments 灵活,只能是最后部分形参参数
  function add(...values) {
    let sum = 0;
    for(value of values) {
      sum += value;
    }
    return sum;
  }
2. 扩展运算符
  let arr1 = [1, 3, 5];
  let arr2 = [2, ...arr1, 6];
  arr2.push(...arr1);
-->
<script type="text/javascript">
  function fun(...values) {
    console.log(arguments);
    console.log(arguments.callee + ''); // 函数本身

    /*arguments.forEach(function (item, index) {
        console.log(item, index);
    });*/
    console.log(values);
    values.forEach(function (item, index) {
      console.log(item, index);
    })
  }

  fun(1, 2, 3);

  let arr = [2, 3, 4, 5, 6];
  let arr1 = ['abc', ...arr, 'fg']; // 插入指定位置
  console.log(arr1);
</script>
</body>
</html>
